<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/5/1
 * Time: 22:03
 */

namespace Lib\Api;


class AgentCommissionSetApi extends UtilsApi {
    private static $modelName = 'AgentCommissionSet';

    /** 获取经纪人返佣设置列表
     * @param $where
     * @param int $page_num
     * @param int $page_size
     * @param string $filed
     * @param string $order
     * @return mixed
     */
    public static function getList($where, $page_num = 1, $page_size = 15, $filed = "*", $order='') {
        $list = parent::getList(AgentCommissionSetApi::$modelName, $where, $page_num, $page_size, $filed, $order);
        return $list;
    }

    /** 获取经纪人返佣设置列表
     * @param $where
     * @param $left
     * @param string $field
     * @param string $order
     * @return mixed
     */
    public static function getAllListByCondition($where, $left='', $field = "*", $order='') {
        $model = M();
        $list = $model->table('fs_agent_commission_set a')
            ->join($left)
            ->field($field)
            ->where($where)
            ->order($order)
            ->select();
        return $list;
    }

    public static function geInfoByCondition($where, $left='', $field = "*", $order="") {
        $model = M();
        $list = $model->table('fs_agent_commission_set a')
            ->join($left)
            ->field($field)
            ->where($where)
            ->order($order)
            ->find();
        return $list;
    }

    /** 获取经纪人返佣设置列表
     * @param $where
     * @param $left
     * @param string $field
     * @param string $order
     * @param int $page_num
     * @param int $page_size
     * @return mixed
     */
    public static function getListByCondition($where, $left='', $field = "*", $order='', $page_num = 1, $page_size = 15) {
        $model = M();
        $list = $model->table('fs_agent_commission_set a')
            ->join($left)
            ->field($field)
            ->where($where)
            ->page($page_num, $page_size)
            ->order($order)
            ->select();
        return $list;
    }

    /** 获取经纪人返佣设置总数
     * @param $where
     * @return mixed
     */
    public static function getTotal($where) {
        $total = parent::getTotal(AgentCommissionSetApi::$modelName, $where);
        return $total;
    }

    /** 获取经纪人返佣设置信息
     * @param $where
     * @param $filed
     * @return mixed
     */
    public static function getInfo($where, $filed= "*") {
        $manager = parent::getInfo(AgentCommissionSetApi::$modelName, $where, $filed);
        return $manager;
    }

    /** 添加经纪人返佣设置
     * @param $data
     * @return mixed
     */
    public static function add($data) {
        $id = parent::add(AgentCommissionSetApi::$modelName, $data);
        return $id;
    }

    /** 修改经纪人返佣设置
     * @param $data
     * @return bool
     */
    public static function save($data) {
       $state = parent::save(AgentCommissionSetApi::$modelName, $data);
        return $state;
    }

    /** 删除经纪人返佣设置
     * @param $where
     */
    public static function delete($where) {
        parent::delete(AgentCommissionSetApi::$modelName, $where);
    }

    /** 批量添加数据
     * @param $data
     * @return mixed
     */
    public static function addAll($data) {
        $model = M(AgentCommissionSetApi::$modelName);
        return $model->addAll($data);
    }
}